package cate.game.activity.dailysign.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.activity.dailysign.DailySignActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBSignDaily;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "每日签到 额外签到请求")
@OperationSetter(value = GDOperation.SIGN_DAILY_SIGN_REWARD_EXTRA)
public class DailySignExtraSignReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;

    @Override
    public MsgConfig conf() {
        return MsgIdBSignDaily.SIGN_DAILY_SIGN_EXTRA_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        DailySignActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        EcResult<DailySignActivity> r = single.onExtraSignUp();
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
        } else {
            r.data.noticeUpdate();
        }
    }
}
